// pages/findRecord/score.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    scores: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    wx.showToast({
      title: '此服务需要连接校园网',
      icon: 'none',
      duration: 2000
    });
    var username = wx.getStorageSync('username');
    wx.showLoading({
      title: '加载中'
    })
    wx.request({
      url: 'https://net.geek51.cn/api/zhjw/grade/',
      method: "GET",
      data: {
        'username': username
      },
      success: function(res) {
        wx.hideLoading();
        if (res.statusCode == 7) {
          wx.showModal({
            title: '提示',
            content: '请将手机连接校园网后重试!',
            showCancel: false,
            success: res => {
              if (res.confirm) {
                qq.switchTab({
                  url: "/pages/my/my"
                })
              }
            }
          })
        } else {
          var scores = res.data.data;
          that.setData({
            scores: scores
          })
        }

      },
      fail: function (res) {
        wx.hideLoading();
        wx.showModal({
          title: '提示',
          content: '请将手机连接校园网后重试!',
          showCancel: false
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  }
})